package com.ambimmort.shj.action.policy;

import com.ambimmort.shj.service.policy.PolicyService;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

/**
 * Created by Josh on 2015/7/30.
 */
@Controller("/action/policy/history_policy_info.do")
public class HistoryPolicyInfo {
    @Autowired
    private PolicyService policyService;

    /**
     *
     * @param request
     * @param response
     * @param type
     * @param instance
     * @param messageNo
     * @return
     * @throws UnsupportedEncodingException
     */
    @RequestMapping("/action/policy/history_policy_info.do")
    @ResponseBody
    public String historyPolicyInfo_policy(HttpServletRequest request,HttpServletResponse response, @RequestParam("type") String type, @RequestParam("instance") String instance,@RequestParam("messageNo") String messageNo) throws UnsupportedEncodingException {
        byte[] instanceArr = Base64.decodeBase64(instance);
       return policyService.historyPolicyInfo(type,instanceArr,messageNo);

    }
}
